var vm = new Vue({
    el:"#app",
    data:{ 
        firstName:'Foo',
        lastName:'Bar'
        //fullName:'Foo Bar'    //验证计算属性时，本语句需要注释掉
    },
    watch:{
        firstName:function(val) {
            this.fullName = val +''+ this.lastName;
        },
        lastName:function(val) {
            this.fullName = this.firstName +''+ val;
        }
    },
    computed:{
        fullname:{
            //getter用于读取
            get:function() {
                return this.firstName +''+ this.lastName;
            },
            //setter写入时触发
            set:function() {
                var names = newValue.split('');
                this.firstName = names[0];
                this.lastName = names[names.length - 1];
            }
        },
    }
})
